﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace 备忘录模式_游戏进度02
{
    class RoleState
    {
        int vit;//生命值
        int atk;//攻击力
        int def;//防御力

        public void SetAttr(int vit,int atk,int def)
        { 
            this.vit = vit;
            this.atk = atk;
            this.def = def;
        }

        public RoleState(int vit,int atk,int def)
        {
            SetAttr(vit, atk, def);
        }

        public RoleStateMemento CreateMemento()
        {
            RoleStateMemento m = new RoleStateMemento();
            m.atk = atk;
            m.vit = vit;
            m.def = def;
            return m;
        }

        public void SetMemento(RoleStateMemento m)
        { 
            atk = m.atk;
            vit = m.vit;
            def = m.def;
        }

        public void Show()
        {
            Console.WriteLine("生命值={0} 攻击力={1} 防御力={2}",vit,atk,def);
            Console.WriteLine();
        }
    }

    class RoleStateMemento
    { 
       public int vit;//生命值
       public int atk;//攻击力
       public int def;//防御力    
    }

    class RoleStateCaretaker
    {
        RoleStateMemento memento;



        public RoleStateCaretaker( )
        {

        }

        public RoleStateCaretaker(RoleStateMemento m)
        {
            memento = m;
        }

        public RoleStateMemento GetIt()
        {
            return memento;
        }
        
        public void SaveIt(RoleStateMemento m)
        {
             memento = m;
        }
    }

}
